package com.study.filter;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import java.io.IOException;

/**
 * 自定义 Filter：需在 web.xml 中配置
 * 启动的顺序为 listener -> filter -> servlet，不会因为在配置文件中的先后顺序而改变。
 *
 * @author Administrator
 */
@Slf4j
public class TestFilter implements Filter {
    @Override
    public void init(FilterConfig arg0) throws ServletException {
        log.info("TestFilter init().......");
    }

    @Override
    public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException {
        log.info("TestFilter doFilter().......");
        arg2.doFilter(arg0, arg1);
    }

    @Override
    public void destroy() {
        log.info("TestFilter destroy().......");
    }
}
